package com.linkmcn.uaa.entity;

import com.linkmcn.mcn.common.model.base.BasePojo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.time.LocalDateTime;

@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel("用户表")
public class User extends BasePojo implements Serializable {
    @ApiModelProperty(value = "用户名")
    private String username;

    @ApiModelProperty(value = "昵称，对应主播名称、机构名称、商家名称")
    private String nickName;

    @ApiModelProperty(value = "真实姓名")
    private String realName;

    @ApiModelProperty(value = "电话")
    private String phone;

    @ApiModelProperty(value = "待绑定的新的电话")
    private String newPhone;

    @ApiModelProperty(value = "邮箱")
    private String email;

    @ApiModelProperty(value = "用户类型 0.平台用户 1.主播 2.机构 3.商家")
    private Integer objType;

    /**
     * com.linkmcn.mcn.model.obj.enums.MarginStatusEnum}
     */
    @ApiModelProperty(value = "是否缴纳保证金 0 否 1是")
    private Integer isMargin;

    @ApiModelProperty(value = "在组织内的id")
    private Long objId;

    @ApiModelProperty(value = "密码 bCrypt加密")
    private String password;

    @ApiModelProperty(value = "支付宝账号")
    private String alipayNum;

    @ApiModelProperty(value = "支付宝名称")
    private String alipayName;


    @ApiModelProperty(value = "支付宝账号是否完成绑定")
    private Boolean isBindAlipayNum;

    @ApiModelProperty(value = "身份证号")
    private String identityNum;

    @ApiModelProperty(value = "身份证姓名")
    private String identityName;

    @ApiModelProperty(value = "是否完成实名认证")
    private Boolean isVerifyIdentity;

    @ApiModelProperty(value = "是否完成人工认证")
    private Boolean manMadeIdentity;

    @ApiModelProperty(value = "人工实名最后操作人")
    private Long manMadeUserId;

    @ApiModelProperty(value = "人工实名最后操作时间")
    private LocalDateTime gmtManMade;

    @ApiModelProperty(value = "商家链接，冗余字段，只对商家有效")
    private String sellerLink;

    @ApiModelProperty(value = "是否启用")
    private Boolean enable;

    @ApiModelProperty(value = "审核驳回原因")
    private String rejectReason;

    @ApiModelProperty(value = "清退原因")
    private String cleanReason;

    @ApiModelProperty(value = "冻结原因")
    private String blockReason;

    @ApiModelProperty(value = "注册时间")
    private LocalDateTime gmtRegister;

    @ApiModelProperty(value = "审核通过时间")
    private LocalDateTime gmtAudit;

    @ApiModelProperty(value = "审核人id")
    private Long auditUserId;

    @ApiModelProperty(value = "头像路径")
    private String headUrl;

    @ApiModelProperty(value = "角色id")
    private Long roleId;

    @ApiModelProperty(value = "是否在其组织内为root账号，即比如商家通过审核，则对应通过审核的账号是商家的根账号")
    private Boolean isRoot;

    @ApiModelProperty(value = "保证金状态  -2.未缴纳保证金 -1.未缴清保证金 0.已缴清保证金")
    private Integer cashDepositStatus;

    @ApiModelProperty(value = "冻结时间")
    private LocalDateTime gmtBlock;

    @ApiModelProperty(value = "冻结人id")
    private Long blockUserId;

    @ApiModelProperty(value = "阿里旺旺号")
    private String wwNum;

    @ApiModelProperty(value = "是否启用客服功能")
    private Boolean isCustServEnable;

    @ApiModelProperty(value = "客服名称")
    private String custServName;
    /**
     * {@link com.linkmcn.user.enums.AuditStatusEnum}
     */
    @ApiModelProperty(value = "认证状态")
    private Integer auditStatus;

    /**
     * 租户ID
     */
    private Long tenantId;



    /**
     * 初始化
     */
    @Override
    public void prepareInsert(Long currentUserId) {
        super.prepareInsert(currentUserId);
        this.setEnable(true);
        this.setGmtRegister(this.getGmtCreate());
        this.setWwNum("");
        this.setCustServName(this.getRealName());
        this.setIsCustServEnable(false);
        this.setIsMargin(0);
    }


    /**
     * 清除隐私信息
     */
    public void clearPrivateInfo() {
        this.setPassword(null);
        this.setPhone(null);
        this.setEmail(null);
        this.setAlipayNum(null);
    }

}
